const http = require('http')

const server = http.createServer()

server.on('request', (req, res) => {
  // 路径
  const url = req.url
  // 请求方法
  const method = req.method
  // 请求头部
  const headers = req.headers
  console.log(url)
  console.log(method)
  console.log(headers)

  // 响应状态码
  res.statusCode = 200
  // 响应头部
  res.setHeader('Content-Type', 'text/plain; charset=utf-8')
  res.end('Hello world!')
})

server.listen(80, () => {
  console.log('Server running at http://127.0.0.1:80/')
})